package gameObject
{
	import flash.events.Event;
	import flash.net.Responder;
	
	import gameObject.resources3D.GameMesh;
	import gameObject.resources3D.WeaponResource;
	
	import ui.component.EquipIcon;
	
	/**
	 *机械库，商店中的高模武器
	 */
	public class WeaponPartSec extends WeaponPartBase
	{
		private var _icon:EquipIcon;
		private var _installed:Boolean;
		
		public function WeaponPartSec(ID:int,inc:int)
		{
			super(ID,inc);
			_icon = new EquipIcon(3,_id,_inc,116,116);
			
			Global.phpServer.call("robotServer.getSecWeaponVals", new Responder(gotValues),ID,inc);
		}
		

		public function get installed():Boolean
		{
			return _installed;
		}

		public function set installed(value:Boolean):void
		{
			_installed = value;
			_icon.installed = value;
		}

		public function get icon():EquipIcon
		{
			return _icon;
		}

		private function gotValues(obj:Object):void
		{
			_wName=obj.name;
			_level=obj.level;
			_cost = obj.cost;
			_bullet=obj.bullet;
			_pow=obj.pow;
			_speed=obj.speed;
			_maxdur=obj.maxdur;
			
			_icon.name = _wName;
			
			//trace(name,level,cost,bullet,pow,speed,maxdur);
			
			_resource = new WeaponResource(2,_id,GameMesh.LOD_HIGH);
			_resource.addEventListener(Event.COMPLETE,resourceLoaded);
			_resource.load();
		}
		
		private function resourceLoaded(e:Event):void
		{
			dispatchEvent(new Event(Event.COMPLETE));
		}
	}
}